﻿@using Vcare.Properties
@model Vcare.Models.Members

@{
    ViewBag.Title = "Edit";
}

<h2>Edit Member</h2>
<div class="spacer"></div>

@using (Html.BeginForm("Edit", "Members", FormMethod.Post, new { name="frmEditMember" }))
{
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Members</legend>

        @Html.HiddenFor(model => model.MembersID)
        @Html.HiddenFor(model => model.Title)
        @Html.HiddenFor(model => model.CallCentreID)
        @Html.HiddenFor(model => model.ValueOfSinglePayment)

        <div class="editor-label">
            @Html.LabelFor(model => model.ContactDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ContactDate)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Phone)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Phone)
            @Html.ValidationMessageFor(model => model.Phone)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Title)
        </div>
        <div class="editor-field">
            @Html.DropDownList("Titles", null, new { name="Title" })
            @Html.ValidationMessageFor(model => model.Title)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Firstname)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Firstname)
            @Html.ValidationMessageFor(model => model.Firstname)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Lastname)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Lastname)
            @Html.ValidationMessageFor(model => model.Lastname)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.housenumber)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.housenumber)
            @Html.ValidationMessageFor(model => model.housenumber)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address)
            @Html.ValidationMessageFor(model => model.Address)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Town)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Town)
            @Html.ValidationMessageFor(model => model.Town)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.County)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.County)
            @Html.ValidationMessageFor(model => model.County)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Postcode)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Postcode)
            @Html.ValidationMessageFor(model => model.Postcode)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.CommentsOnBoxType)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CommentsOnBoxType)
            @Html.ValidationMessageFor(model => model.CommentsOnBoxType)
        </div>
        @if (this.User.IsInRole(ApplicationRoles.CallCentreQC))
        {
        <div class="editor-label">
            @Html.LabelFor(model => model.QAd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.QAd)
            @Html.ValidationMessageFor(model => model.QAd)
        </div>
        }
        <div class="spacer"></div>        
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

<script type="text/javascript">
    $(document).ready(function () {

        $('#ContactDate').val('@(DateTime.Now.ToShortDateString())');
        $("#Titles").val("@(Model.Title)");
        $("#PaymentType").val("@(Model.PaymentType)");
        $("#PricePlan").val("@((int)Model.ValueOfSinglePayment)");
        $("#PaymentOption").val("@(Model.PaymentOption)");
        $(".maestro").toggle();

        $("#ExpiryDate").mask("9999");
        $("#StartDate").mask("9999");

        $("#Titles").change(function () {
            $("#Title").val($(this).val());
        });

        $(function () {
            $("#ContactDate").datepicker({
                changeMonth: true,
                changeYear: true,
                regional: 'en-GB',
                dateFormat: 'dd/mm/yy'
            });
        });

        $("#CardType").change(function () {
            if ($("#CardType").val() == "Maestro") {
                $(".maestro").toggle();
                MaestroFlag = true;
            }
            else if (MaestroFlag == true) {
                $(".maestro").toggle();
                MaestroFlag = false;
            }
        });
    });
</script>

